{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 量子生成对抗网络"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<em> Copyright (c) 2021 Institute for Quantum Computing, Baidu Inc. All Rights Reserved. </em>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 经典生成对抗网络"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 生成对抗网络简介"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "生成对抗网络（generative adversarial network, GAN）是生成模型的一种，是深度学习在近些年中一个重要的发展[1]。它分为两个部分：生成器 $G$（generator）和判别器 $D$ (discriminator)。生成器接受随机的噪声信号，以此为输入来生成我们期望得到的数据。判别器判断接收到的数据是不是来自真实数据，通常输出一个 $P(x)$，表示输入数据 $x$ 是真实数据的概率。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 纳什均衡"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在这里，我们用纳什均衡的思想来探讨 GAN 的收敛问题。\n",
    "\n",
    "纳什均衡（Nash equilibrium）是指在包含两个或以上参与者的非合作博弈（non-cooperative game）中，假设每个参与者都知道其他参与者的均衡策略的情况下，没有参与者可以通过改变自身策略使自身受益时的一个概念解。在博弈论中，如果每个参与者都选择了自己的策略，并且没有玩家可以通过改变策略而其他参与者保持不变而获益，那么当前的策略选择的集合及其相应的结果构成了纳什均衡。\n",
    "\n",
    "我们可以把GAN的训练过程视为生成器和判别器的博弈过程。在这个博弈过程中，无论生成器的策略是什么，判别器最好的策略就是尽量判别出真实数据和生成数据。而无论判别器的策略是什么，生成器最好的策略就是使判别器无法判别出来。我们不难发现，这种博弈是零和博弈（一种非合作博弈），即一方有所得则另一方必有所失。因此生成器和判别器的博弈存在这种纳什均衡策略。而当真实数据的样本足够多，双方的学习能力足够强时，最终就会达到一种纳什均衡点。**生成器具备了生成真实数据的能力，而判别器也无法再区分生成数据和真实数据。**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 优化目标"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在 GAN 中，我们重点想要得到的是一个优秀的生成器（但是只有优秀的判别器才能准确判断生成器是否优秀），所以我们训练的理想结果是判别器无法识别出数据是来自真实数据还是生成数据。\n",
    "\n",
    "因此我们的目标函数如下：\n",
    "\n",
    "$$\n",
    "\\min_{G}\\max_{D} V(G,D)= \\min_{G}\\max_{D}\\mathbb{E}_{x\\sim P_{data}}[\\log D(x)]+\\mathbb{E}_{z\\sim P_{z}}[\\log(1-D(G(z)))]. \\tag{1}\n",
    "$$\n",
    "\n",
    "这里，$G$ 表示生成器的参数，$D$ 表示判别器的参数。实际过程中，通常采用交替训练的方式，即先固定 $G$，训练 $D$，然后再固定 $D$，训练 $G$，不断往复。当两者的性能足够时，模型会收敛，两者达到纳什均衡。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 优点"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 相对其他生成模型，GAN 的生成效果更好。\n",
    "- 理论上，只要是可微分函数都可以用于构建生成器和判别器，因此能够与深度神经网络结合做深度生成模型。\n",
    "- GAN 相对其他生成模型来说，不依赖先验假设，我们事先不需要假设数据的分布和规律。\n",
    "- GAN 生成数据的形式也很简单，只需要通过生成器进行前向传播即可。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 缺点"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- GAN 无需预先建模，因此过于自由导致训练难以收敛而且不稳定。\n",
    "- GAN 存在梯度消失问题，即很可能会达到这样一种状态，判别器的效果特别好，生成器的效果特别差。在这种情况下，判别器的训练没有任何损失，因此也没有有效的梯度信息去回传给生成器让它优化自己。\n",
    "- GAN 的学习过程可能出现模式崩溃（model collapse）问题。生成器发生退化，总是生成同样的样本点，无法继续学习。而此时，判别器也会对相似的样本点指向相似的方向，模型参数已经不再更新，但是实际效果却很差。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 量子生成对抗网络"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "量子生成对抗网络与经典的类似，只不过不再用于生成经典数据，而是生成量子态[2-3]。在实践中，如果我们有一个量子态，其在观测后会坍缩为某一本征态，无法恢复到之前的量子态。因此如果我们有一个方法可以根据已有的目标量子态生成出很多与之相同（或相近）的量子态，会很方便我们的实验。\n",
    "\n",
    "假设我们已有的目标量子态是一个混合态，它们属于同一个系综，其密度算符为$\\rho$。然后我们需要有一个生成器 $G$，它的输入是一个噪声数据，我们用一个系综 $\\rho_{z}=\\sum_{i}p_{i}|z_{i}\\rangle\\langle z_{i}|$ 来表示。因此我们每次取出一个随机噪声样本 $|z_{i}\\rangle$，通过生成器后得到生成的量子态 $|x\\rangle=G|z_{i}\\rangle$，我们期望生成的 $|x\\rangle$ 与目标量子态$\\rho$相近。\n",
    "\n",
    "值得注意的是，对于上文中提到的目标态的系综和噪声数据的系综，我们都认为有一个已有的物理设备可以生成出一个该系综下的量子态，而由于量子物理的相关性质，我们每次可以得到一个真正随机的量子态。但是在计算机程序中，我们仍然只能模拟这一过程。\n",
    "\n",
    "对于判别器，我们期望判别器可以判断我们输入的量子态是已有的目标态还是生成的量子态，这一过程可以由测量给出。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 一个简单的例子"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 问题描述"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "简单起见，我们假设已有的目标量子态是一个纯态，且生成器接受的输入为$|0\\rangle$。\n",
    "\n",
    "制备已有的目标量子态的线路：\n",
    "![QGAN-fig-target_state](figures/QGAN-fig-target_state.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "生成器的线路为：\n",
    "![QGAN-fig-generator](figures/QGAN-fig-generator.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "判别器的线路为：\n",
    "![QGAN-fig-discriminator](figures/QGAN-fig-discriminator.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过对判别器输出的量子态进行测量，我们可以得到将目标态判断为目标态的概率 $P_{T}$ 和将生成态判断为目标态的概率 $P_{G}$（通过对判别器连接目标态和生成器这两个不同的输入得到）。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 具体过程"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "假设已有的目标量子态为 $|\\psi\\rangle$，生成器生成的量子态为 $|x\\rangle=G|00\\rangle$（生成器采用两量子比特线路，其中第0个量子比特认为是生成的量子态）。\n",
    "\n",
    "判别器对数据进行判别并得到量子态$|\\phi\\rangle$，那么当输入为目标态时，$|\\phi\\rangle=D(|\\psi\\rangle\\otimes |00\\rangle)$；当输入为生成态时，$|\\phi\\rangle=D(G\\otimes I)|000\\rangle$。\n",
    "\n",
    "对于判别器得到的量子态，我们还需要采用泡利 Z 门对第3个量子比特进行测量，从而得到判别器对输入量子态的判断结果（即判别器认为输入是目标态的概率）。首先有 $M_{z}=I\\otimes I\\otimes\\sigma_{z}$，而测量结果为 $\\text{disc_output}=\\langle\\phi|M_{z}|\\phi\\rangle$，所以测量结果为目标态的概率是 $P=(\\text{disc_output}+1)/2$。\n",
    "\n",
    "我们定义判别器的损失函数为 $\\mathcal{L}_D=P_{G}(\\text{gen_theta}, \\text{disc_phi})-P_{T}(\\text{disc_phi})$，生成器的损失函数为 $\\mathcal{L}_{G}=-P_{G}(\\text{gen_theta}, \\text{disc_phi})$。这里的 $P_{G}$ 和 $P_{T}$ 分别是输入量子态为生成态和目标态时，$P=(\\text{disc_output}+1)/2$ 的表达式，gen_theta 和 disc_phi 分别是生成器和判别器线路的参数。\n",
    "\n",
    "因此我们只需要分别优化目标函数 $\\min_{\\text{disc_phi}}\\mathcal{L}_{D}$ 和 $\\min_{\\text{gen_theta}}\\mathcal{L}_{G}$ 即可交替训练判别器和生成器。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 在 Paddle Quantum 上的实现"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "首先导入相关的包。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import paddle\n",
    "from paddle_quantum.circuit import UAnsatz\n",
    "from paddle_quantum.utils import partial_trace, dagger, state_fidelity\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "然后定义我们的网络模型 QGAN。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "class QGAN(paddle.nn.Layer):\n",
    "    def __init__(self):\n",
    "        super(QGAN, self).__init__()\n",
    "        \n",
    "        # 用以制备目标量子态的角度\n",
    "        target_omega_0 = 0.9 * np.pi\n",
    "        target_omega_1 = 0.2 * np.pi\n",
    "        self.target_omega = paddle.to_tensor(\n",
    "            np.array([target_omega_0, target_omega_1], np.float64))\n",
    "        \n",
    "        # 生成器和判别器电路的参数\n",
    "        self.gen_theta = self.create_parameter([9], \n",
    "        dtype=\"float64\", default_initializer=paddle.nn.initializer.Uniform(\n",
    "                            low=0.0, high=np.pi))\n",
    "        self.disc_phi = self.create_parameter([9], \n",
    "        dtype=\"float64\", default_initializer=paddle.nn.initializer.Uniform(\n",
    "                            low=0.0, high=np.pi))\n",
    "        \n",
    "        # 制备目标量子态\n",
    "        cir = UAnsatz(3)\n",
    "        cir.ry(self.target_omega[0], 0)\n",
    "        cir.rz(self.target_omega[1], 0)\n",
    "        self.target_state = cir.run_state_vector()\n",
    "\n",
    "    def generator(self, theta):\n",
    "        \"\"\"\n",
    "        生成器的量子线路\n",
    "        \"\"\"\n",
    "        cir = UAnsatz(3)\n",
    "        cir.u3(*theta[:3], 0)\n",
    "        cir.u3(*theta[3:6], 1)\n",
    "        cir.cnot([0, 1])\n",
    "        cir.u3(*theta[6:], 0)\n",
    "\n",
    "        return cir\n",
    "\n",
    "    def discriminator(self, phi):\n",
    "        \"\"\"\n",
    "        判别器的量子线路\n",
    "        \"\"\"\n",
    "        cir = UAnsatz(3)\n",
    "        cir.u3(*phi[:3], 0)\n",
    "        cir.u3(*phi[3:6], 2)\n",
    "        cir.cnot([0, 2])\n",
    "        cir.u3(*phi[6:], 0)\n",
    "\n",
    "        return cir\n",
    "\n",
    "    def disc_target_as_target(self):\n",
    "        \"\"\"\n",
    "        判别器将目标态判断为目标态的概率\n",
    "        \"\"\"\n",
    "        # 判别器电路\n",
    "        cir = self.discriminator(self.disc_phi)\n",
    "        cir.run_state_vector(self.target_state)\n",
    "        \n",
    "        # 判别器对目标态的判断结果\n",
    "        target_disc_output = cir.expecval([[1.0, 'z2']])\n",
    "        prob_as_target = (target_disc_output + 1) / 2\n",
    "\n",
    "        return prob_as_target\n",
    "\n",
    "    def disc_gen_as_target(self):\n",
    "        \"\"\"\n",
    "        判别器将生成态判断为目标态的概率\n",
    "        \"\"\"\n",
    "        # 得到生成器生成的量子态\n",
    "        gen_state = self.generator(\n",
    "                    self.gen_theta).run_state_vector()\n",
    "        # 判别器电路\n",
    "        cir = self.discriminator(self.disc_phi)\n",
    "        cir.run_state_vector(gen_state)\n",
    "        # 判别器对生成态的判断结果\n",
    "        gen_disc_output = cir.expecval([[1.0, 'z2']])\n",
    "        prob_as_target = (gen_disc_output + 1) / 2\n",
    "        \n",
    "        return prob_as_target\n",
    "\n",
    "    def forward(self, model_name):\n",
    "        if model_name == 'gen':\n",
    "            # 计算生成器的损失函数，loss值的区间为[-1, 0]，\n",
    "            # 0表示生成效果极差，为-1表示生成效果极好\n",
    "            loss =  -1 * self.disc_gen_as_target()\n",
    "        else:\n",
    "            # 计算判别器的损失函数，loss值的区间为[-1, 1]，\n",
    "            # 为-1表示完美区分，为0表示无法区分，为1表示区分颠倒\n",
    "            loss = self.disc_gen_as_target() - self.disc_target_as_target()\n",
    "\n",
    "        return loss\n",
    "\n",
    "    def get_target_state(self):\n",
    "        \"\"\"\n",
    "        得到目标态的密度矩阵表示\n",
    "        \"\"\"\n",
    "        state = self.target_state\n",
    "        state = paddle.reshape(state, [1] + state.shape)\n",
    "        density_matrix = paddle.matmul(dagger(state), state)\n",
    "        state = partial_trace(density_matrix, 2, 4, 2)\n",
    "\n",
    "        return state.numpy()\n",
    "\n",
    "    def get_generated_state(self):\n",
    "        \"\"\"\n",
    "        得到生成态的密度矩阵表示\n",
    "        \"\"\"\n",
    "        state = self.generator(self.gen_theta).run_state_vector()\n",
    "        state = paddle.reshape(state, [1] + state.shape)\n",
    "        density_matrix = paddle.matmul(dagger(state), state)\n",
    "        state = partial_trace(density_matrix, 2, 4, 2)\n",
    "\n",
    "        return state.numpy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "接下来我们使用 PaddlePaddle 来训练我们的模型。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Training: 100%|#################################################| 1050/1050 [01:27<00:00, 12.01it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the density matrix of the target state:\n",
      "[[0.02447174+0.00000000e+00j 0.125     +9.08178160e-02j]\n",
      " [0.125     -9.08178160e-02j 0.97552826+5.16498656e-18j]] \n",
      "\n",
      "the density matrix of the generated state:\n",
      "[[0.0244643 -5.29696618e-19j 0.12657544+8.85689120e-02j]\n",
      " [0.12657544-8.85689120e-02j 0.9755357 -2.82739625e-19j]] \n",
      "\n",
      "the distance between these two quantum states is 1.5079277656078345e-05 \n",
      "\n",
      "the fidelity between these two quantum states is 0.9999962306522913\n"
     ]
    }
   ],
   "source": [
    "# 学习率\n",
    "LR = 0.1\n",
    "# 总的迭代次数\n",
    "ITR = 15\n",
    "# 每次迭代时，判别器的迭代次数\n",
    "ITR1 = 20\n",
    "# 每次迭代时，生成器的迭代次数\n",
    "ITR2 = 50\n",
    "\n",
    "# 用来记录loss值的变化\n",
    "loss_history = list()\n",
    "paddle.seed(18)\n",
    "gan_demo = QGAN()\n",
    "optimizer = paddle.optimizer.SGD(learning_rate=LR, parameters=gan_demo.parameters())\n",
    "pbar = tqdm(desc=\"Training: \", total=ITR * (ITR1 + ITR2), ncols=100, ascii=True)\n",
    "for itr0 in range(ITR):\n",
    "\n",
    "    # 记录判别器loss值的变化\n",
    "    loss_disc_history = list()\n",
    "\n",
    "    # 训练判别器\n",
    "    for itr1 in range(ITR1):\n",
    "        pbar.update(1)\n",
    "        loss_disc = gan_demo('disc')\n",
    "        loss_disc.backward()\n",
    "        optimizer.minimize(loss_disc, parameters=[gan_demo.disc_phi],\n",
    "                           no_grad_set=[gan_demo.gen_theta])\n",
    "        gan_demo.clear_gradients()\n",
    "        loss_disc_history.append(loss_disc.numpy()[0])\n",
    "\n",
    "    # 记录生成器loss值的变化\n",
    "    loss_gen_history = list()\n",
    "\n",
    "    # 训练生成器\n",
    "    for itr2 in range(ITR2):\n",
    "        pbar.update(1)\n",
    "        loss_gen = gan_demo('gen')\n",
    "        loss_gen.backward()\n",
    "        optimizer.minimize(loss_gen, parameters=[gan_demo.gen_theta],\n",
    "                           no_grad_set=[gan_demo.disc_phi])\n",
    "        optimizer.clear_grad()\n",
    "        loss_gen_history.append(loss_gen.numpy()[0])\n",
    "\n",
    "    loss_history.append((loss_disc_history, loss_gen_history))\n",
    "pbar.close()\n",
    "\n",
    "# 得到目标量子态\n",
    "target_state = gan_demo.get_target_state()\n",
    "\n",
    "# 得到生成器最终生成的量子态\n",
    "gen_state = gan_demo.get_generated_state()\n",
    "print(\"the density matrix of the target state:\")\n",
    "print(target_state, \"\\n\")\n",
    "print(\"the density matrix of the generated state:\")\n",
    "print(gen_state, \"\\n\")\n",
    "\n",
    "# 计算两个量子态之间的距离，\n",
    "# 这里的距离定义为 tr[(target_state-gen_state)^2]\n",
    "distance = np.trace(np.matmul(target_state-gen_state, \n",
    "                              target_state-gen_state)).real\n",
    "# 计算两个量子态的保真度\n",
    "fidelity = state_fidelity(target_state, gen_state)\n",
    "print(\"the distance between these two quantum states is\", distance, \"\\n\")\n",
    "print(\"the fidelity between these two quantum states is\", fidelity)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们通过比较目标量子态和生成量子态的密度矩阵 $\\rho_\\text{target}$ 和 $\\rho_\\text{gen}$ 以及计算它们之间的距离 $\\text{tr}[(\\rho_\\text{target}-\\rho_\\text{gen})^2]$ 和保真度可以得知，我们的生成器生成了一个与目标态很相近的量子态。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 训练过程的可视化"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "接下来我们观察一下，在训练过程中，判别器和生成器的 loss 曲线变化过程。\n",
    "\n",
    "首先安装所需要的 package。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import clear_output\n",
    "!pip install celluloid\n",
    "clear_output()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "接下来，我们绘制 loss 曲线的变化。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAEXCAYAAACQ3VJYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAmJklEQVR4nO3deZhdVZnv8e+PJASEMHMxJIRECUMEDFAGkRaRSS7QJgzKIBpso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jBmZlaI/w8EtZGfjgBAmAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from celluloid import Camera\n",
    "def draw_pic(loss_history):\n",
    "    fig, axes = plt.subplots(nrows=1, ncols=2)\n",
    "    camera = Camera(fig)\n",
    "    axes[0].set_title(\"discriminator\")\n",
    "    axes[0].set_xlabel(\"disc_iter\")\n",
    "    axes[0].set_ylabel(\"disc_loss\")\n",
    "    axes[0].set_xlim(0, 20)\n",
    "    axes[0].set_ylim(-1, 1)\n",
    "    axes[1].set_title(\"generator\")\n",
    "    axes[1].set_xlabel(\"gen_iter\")\n",
    "    axes[1].set_ylabel(\"gen_loss\")\n",
    "    axes[1].set_xlim(0, 50)\n",
    "    axes[1].set_ylim(-1, 0)\n",
    "    for loss in loss_history:\n",
    "        disc_data, gen_data = loss\n",
    "        disc_x_data = range(0, len(disc_data))\n",
    "        gen_x_data = range(0, len(gen_data))\n",
    "        axes[0].plot(disc_x_data, disc_data, color='red')\n",
    "        axes[1].plot(gen_x_data, gen_data, color='blue')\n",
    "        camera.snap()\n",
    "    animation = camera.animate(interval=600, \n",
    "                               repeat=True, repeat_delay=800)\n",
    "    animation.save(\"./figures/loss.gif\")\n",
    "draw_pic(loss_history)\n",
    "clear_output()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![QGAN-fig-loss](figures/loss.gif)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在这个动态图片中，每个帧代表一次迭代的过程。在一次迭代中，左边的红线表示判别器的 loss 曲线，右边的蓝线表示生成器的 loss 曲线。可以看出，在初始的时候，判别器和生成器每次都能从一个比较差的判别能力和生成能力逐渐学习到当前情况下比较好的判别能力和生成能力。随着学习的进行，生成器的生成能力越来越强，判别器的能力也越来越强，但是却也无法判别出真实数据和生成数据，因为这种时候生成器已经生成出了接近真实数据的生成数据，此时模型已经收敛。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "_______\n",
    "\n",
    "## 参考文献"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[1] Goodfellow, I. J. et al. Generative Adversarial Nets. [Proc. 27th Int. Conf. Neural Inf. Process. Syst. (2014).](https://papers.nips.cc/paper/5423-generative-adversarial-nets)\n",
    "\n",
    "[2] Lloyd, S. & Weedbrook, C. Quantum Generative Adversarial Learning. [Phys. Rev. Lett. 121, 040502 (2018).](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.121.040502)\n",
    "\n",
    "[3] Benedetti, M., Grant, E., Wossnig, L. & Severini, S. Adversarial quantum circuit learning for pure state approximation. [New J. Phys. 21, (2019).](https://iopscience.iop.org/article/10.1088/1367-2630/ab14b5)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
